/**
 * ======================================
 * 企业端
 * author: sky52
 * file: enterprise.vue
 * date: 2022/7/10 22:43
 * ======================================
 */
<template>
  <div class="login-container">
    <el-row>
      <el-col :span="24">
        <div class="top-title">{{ title }}</div>
      </el-col>
    </el-row>
    <div class="content-wrap">
      <div v-if="isScan" style="flex: 1">
        <el-row>
          <el-col :span="12">
            <div class="title-container" style="margin: 40px 0 0 40px;">
              <h3 class="title">扫码登录</h3>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="title-container" style="margin: 40px 40px 0 0">
              <h3 class="title" style="text-align: right;font-size: 16px;cursor: pointer" @click="changeWay">使用账号登录</h3>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="title-container" style="margin: 40px 0 20px 0;">
              <h3 class="title" style="text-align: center">使用微信扫一扫登录</h3>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <div style="width: 100%;height: 10px;" />
          </el-col>
          <el-col :span="12">
            <div style="width: 100%;display: flex;">
              <div style="width: 210px;height: 210px;margin: auto;border: #000 1px solid;display: flex"><div ref="qrcode" style="margin: auto" /></div>
            </div>
          </el-col>
          <el-col :span="6">
            <div style="width: 100%;height: 10px;" />
          </el-col>
        </el-row>
        <div class="title-container" style="margin: 20px 0 0 0;">
          <h3 class="title" style="text-align: center;font-size: 16px;cursor: pointer" @click="refreshCode">刷新&emsp;<i
            class="el-icon-refresh-right"
          /></h3>
        </div>
      </div>
      <div v-else style="flex: 1">
        <div class="qc-code" @click="changeWay" />
        <el-form
          ref="loginForm"
          :model="loginForm"
          :rules="loginRules"
          class="login-form"
          auto-complete="on"
          label-position="left"
        >

          <div class="title-container">
            <h3 class="title">登录账号</h3>
          </div>

          <el-form-item prop="username">
            <span class="svg-container">
              <svg-icon icon-class="user" />
            </span>
            <el-input
              ref="username"
              v-model="loginForm.username"
              placeholder="请输入账号"
              name="username"
              type="text"
              tabindex="1"
              auto-complete="on"
            />
          </el-form-item>

          <div class="title-container">
            <h3 class="title">登陆密码</h3>
          </div>

          <el-form-item prop="password">
            <span class="svg-container">
              <svg-icon icon-class="password" />
            </span>
            <el-input
              :key="passwordType"
              ref="password"
              v-model="loginForm.password"
              :type="passwordType"
              placeholder="请输入密码"
              name="password"
              tabindex="2"
              auto-complete="on"
              @keyup.enter.native="handleLogin"
            />
            <span class="show-pwd" @click="showPwd">
              <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
            </span>
          </el-form-item>

          <el-button :loading="loading" type="primary" @click.native.prevent="handleLogin">立即登陆</el-button>

        </el-form>
        <!--        <div class="tips">忘记密码?</div>-->
      </div>
      <div style="flex: 1;overflow: hidden;display: flex">
        <img src="../../assets/login_image.png" style="height: 382px;margin: auto;width: 393px;" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import main from './main'
export default {
  name: 'Login',
  mixins: [main],
  data() {
    return {
      type: 3
    }
  }
}
</script>

<style lang="scss">
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */

$bg: #283443;
$light_gray: #fff;
$cursor: #fff;

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}

/* reset element-ui css */
.login-container {
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;

    input {
      background: transparent;
      border: 0px;
      -webkit-appearance: none;
      border-radius: 0px;
      padding: 12px 5px 12px 15px;
      //color: $light_gray;
      color: #454545;
      height: 47px;
      caret-color: #000;
      font-size: 18px;

      &:-webkit-autofill {
        box-shadow: 0 0 0px 1000px $bg inset !important;
        -webkit-text-fill-color: $cursor !important;
      }
    }
  }

  .el-form-item {
    //background: rgba(0, 0, 0, 0.1);
    border-radius: 46px;
    box-sizing: border-box;
    background: #FFFFFF;
    border: 1px solid #EFF0F6;
    box-shadow: 0px 2px 6px 0px rgba(19, 18, 66, 0.07);
    color: #454545;
    margin-bottom: 30px;
  }
}
</style>

<style lang="scss" scoped>
$bg: #fff;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;

  .top-title {
    position: relative;
    top: 180px;
    left: 76px;
    font-family: SourceHanSansCN-Bold;
    font-size: 36px;
    font-weight: bold;
    color: #3D3D3D;
    text-align: center;
  }

  .content-wrap {
    position: relative;
    box-sizing: border-box;
    border: 1px solid #FFFFFF;
    border-radius: 10px;
    box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.1);
    //width: 60vw;
    width: 957px;
    left: calc(50vw - 478px);
    //height: 56vh;
    height: 510px;
    top: calc(50vh - 255px);
    background: #FFFFFF;
    display: flex;

    .qc-code {
      width: 90px;
      height: 93px;
      margin-bottom: 6px;
      //transform: rotate(180deg);
      cursor: pointer;
      background: url(../../assets/qccode.png);
    }

    .el-button {
      width: 100%;
      overflow: hidden !important;
      height: 47px;
      border-radius: 86px;
      background: #4A3AFF;
      box-shadow: 0px 8px 20px 0px rgba(74, 58, 255, 0.26);
      font-family: SourceHanSansCN-Bold;
      font-size: 18px;
      font-weight: bold;
      color: #FFFFFF;
    }
  }

  .login-form {
    position: relative;
    //width: 520px;
    width: 80%;
    max-width: 100%;
    //padding: 160px 35px 0;
    margin: 0 auto;
    overflow: hidden;
  }

  .tips {
    font-family: SourceHanSansCN-ExtraLight;
    font-size: 16px;
    color: #6F6C90;
    text-align: center;
    margin-top: 1.2vh;
    cursor: pointer;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
  }

  .title-container {
    position: relative;

    .title {
      font-family: SourceHanSansCN-Bold;
      font-size: 18px;
      color: #170F49;
      //color: $light_gray;
      margin: 0px auto 15px auto;
      text-align: left;
      font-weight: bold;
    }
  }

  .show-pwd {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
  }
}
</style>
